<%--
  Created by IntelliJ IDEA.
  User: dqf
  Date: 2015/3/11
  Time: 13:39
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName()
            + path + "/com";
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>知识共享信息</title>
    <jsp:include page="../../../main/mp/inc.jsp"	/>
    <style>
        div[name="p"]{width:100% !important}
        div[name="p"] img{width:100% !important}
        div.WACPageBorder{position:static !important}
        #WACScroller{width:100% !important}

        .toolAndroid {
              position:fixed !important;
              bottom: -11px !important;
              left:0px !important;
              width:100% !important;
              background-color:gainsboro;
          }
          .btn-txt[class='ui-btn-icon-left']{
              padding-left: 1.6em !important;
          }

          .toolIos{
             position:absolute !important;
             bottom: -11px !important;
             left:0px !important;
             width:99% !important;
             background-color:gainsboro;
          }
    </style>
    <script>
        $(function(){
            $("[data-role='navbar']").navbar();
            $("[data-role='header'], [data-role='footer']").toolbar();
        });
        $( document ).on( "pageshow", "[data-role='page']", function() {
            try {
                WeixinJSBridge.call('hideToolbar');
                WeixinJSBridge.call('hideOptionMenu');
            } catch (e) {

            }
            var current = $( this ).jqmData( "title" );
            $( "[data-role='navbar'] a" ).removeClass( "ui-btn-active" );
            $( "[data-role='navbar'] a" ).each(function() {
                var id = current=="基础信息"?"base_info":"desc_info";
                $( "#"+id ).addClass( "ui-btn-active" );
            });
        });
        $(function(){
//				基础信息隐藏图文信息显示
            $("#desc_info").click(function(){
                $("#page_main").hide();
                $("#product_info").show();
                $("#doc_div").hide();
            });
            $("#base_info").click(function(){
                $("#page_main").show();
                $("#product_info").hide();
                $("#doc_div").hide();
            });
            $("#doc_info").click(function(){
                $("#page_main").hide();
                $("#product_info").hide();
                $("#doc_div").show();
            });
        })
    </script>

</head>

<body>
    <!-- class="jqm-demos" -->
    <input type="hidden" id="hi_ids" value=""/>
    <div data-role="header" data-position="fixed" data-theme="a" id="head-div">
        <a href="ajax!knowledge.action" data-ajax="false" id="" class="ui-btn ui-btn-left ui-icon-back ui-corner-all ui-btn-icon-left ui-btn-icon-notext">视图</a>
        <h1  style="float:left;margin: 0 40px;">知识列表</h1>
        <div data-role="controlgroup" data-type="horizontal" class="ui-mini ui-btn-right">
            <a href="#" id="page-comment-action" class="ui-btn ui-shadow ui-btn-inline ui-icon-check ui-btn-a ui-corner-all ui-btn-icon-left">批注</a>
            <a href="#" id="page-file-action" class="ui-btn ui-shadow ui-btn-inline ui-icon-check ui-btn-a ui-corner-all ui-btn-icon-left">文件阅览</a>
        </div>

        <div data-role="navbar"  data-iconpos="left">
            <ul data-ajax="false" >
                <li><a href="#" id="base_info" data-icon="home" class="ui-btn-active">基础信息</a></li>
                <li><a href="#" id="desc_info" data-icon="info" >图文信息</a></li>
            </ul>
        </div>
    </div><!-- /header -->

    <div data-role="page"  id="page_main_content" data-title="基础信息">
        <div class="ui-content jqm-content jqm-fullwidth" role="main">
            <div id="page_main" >
                <form method="post" id="form-common" data-ajax="false">
                    <input type="hidden" id="createrId" name="createrId" value="<s:property value="knowledge.creater.id" />">
                    <input type="hidden" id="keyId" name="keyId" value="<s:property value="knowledge.id" />">
                    <div class="ui-field-contain">
                        <label>标题：</label>
                        <span><s:property value="knowledge.name" /></span>
                    </div>
                    <div class="ui-field-contain">
                        <label>知识大类：</label>
                        <span><s:property value="knowledge.superType.name" /></span>
                    </div>

                    <div class="ui-field-contain">
                        <label>知识小类：</label>
                        <span><s:property value="knowledge.subType.name" /></span>
                    </div>
                </form>
            </div>
            <div id="product_info" style="display: none">
                <s:property escape='0' value="knowledge.contextHtml" />
            </div>

        </div><!-- /content -->
    </div><!-- /page -->



    <!-- 页面批注-->
    <div data-role="page" id="page-comment" data-theme="a" style="padding-top: 0px !important;"
                   targetId="<s:property value="knowledge.id" />"
                   targetObject="com.joint.core.entity.Knowledge"
                   data="{}" createrId="<s:property value="knowledge.creater.id" />">
        <div data-role="header"  >
            <a href="#" key="page-main-action" data-ajax="false"
               class="ui-btn ui-btn-left ui-icon-back ui-corner-all ui-btn-icon-left ui-btn-icon-notext">视图</a>
            <h1>批注信息</h1>
            <%--<a href="#" key="comment-popup2" data-rel="popup" parentId=''--%>
               <%--createrName='<s:property value="knowledge.creater.name"/> 请填写批注信息'--%>
               <%--createrId='<s:property value="knowledge.creater.id"/>' data-transition="pop"--%>
               <%--class="ui-btn ui-btn-right ui-icon-comment ui-corner-all ui-btn-icon-left ui-btn-icon-notext"--%>
               <%--data-position-to="window" data-icon="comment" data-prefetch="true">发表批注</a>--%>
        </div><!-- /header -->
        <div role="main" class="ui-content" id="comment-listview-content"
             mp-url="ajax-comment!listDocument.action?keyId=<s:property value="knowledge.id" />">
            <ul data-role="listview" data-theme="a" data-dividertheme="b"
                mp-page="1" mp-keyword="" data-split-icon="forward" data-split-theme="a" data-inset="false">
                <li><a data-ajax="false"  href="javascript:void(0)">
                    没有批注信息.
                </a>
                </li>
            </ul>
            <%--<div>--%>
                <%--<a href="#" key="prePage" class="ui-btn ui-btn-icon-notext ui-corner-all  ui-mini ui-btn-inline ui-icon-carat-l "> 上一页</a>--%>
                <%--<a href="#" key="nextPage" class="ui-btn ui-btn-icon-notext ui-corner-all  ui-mini ui-btn-inline ui-icon-carat-r ">下一页 </a>--%>
                    <%--<span class="ui-btn-inline">--%>
                        <%--页数  <span key="pageNumber"></span>/<span key="pageCount"></span> 共<span key="totalCount"></span>条--%>
                    <%--</span>--%>
            <%--</div>--%>
            <div style="height: 40px;">

            </div>
            <div id="ToolBar" >
                <table style="width:100%">
                    <tr>
                        <td>
                            <img id="btn_choose" src="../resource/com/img/add-18.png" style="float: right;"/>
                        </td>
                        <td>
                            <input type="text" placeholder="请输入内容" id="chart_user"  name="chart_user" />
                        </td>
                        <td>
                            <img id="chart_btn" src="../resource/com/img/yes-19.png"  style="float: left"/>
                        </td>
                    </tr>
                </table>
            </div>
            <%--<div data-role="popup" id="comment-popup2" data-theme="a" class="ui-corner-all" data-history="false" data-corners="false">--%>
                <%--<a href="#" data-rel="back" class="ui-btn ui-corner-all ui-shadow ui-btn-a ui-icon-delete ui-btn-icon-notext ui-btn-left">Close</a>--%>
                <%--<form>--%>
                    <%--<div style="padding:0 8px;">--%>
                        <%--<textarea cols="40" rows="8" name="comment" placeholder="请填写您的批注信息"></textarea>--%>
                        <%--<button type="button" class="ui-btn ui-corner-all ui-shadow ui-btn-b ui-btn-icon-left ui-icon-check">提交批注</button>--%>
                        <%--         </div>--%>
                <%--</form>--%>
            <%--</div>--%>

        </div><!-- /content -->
        <div style="height: 40px;">

        </div>
    </div><!-- /page comment -->


    <div data-role="page" id="page-file" data-theme="a" style="padding-top: 0px !important;">
        <div data-role="header"  >
            <div role="main" class="ui-content" id="file-content">
                <input type="hidden" id="fileUrl" value="<s:property value="fileUrl" />">
                <input type="hidden" id="urlData" value="<s:property value="urlData" />">
                <input type="hidden" id="prefix" value="<s:property value="prefix" />">
                <input type="hidden" id="configType" value="<s:property value="configType" />">
            </div>
        </div><!-- /header -->

    </div>
    <div data-role="page" id="page-user" data-theme="a">
        <div data-role="header"  data-position="fixed">
            <a href="#page-comment" key="page-comment-action" data-ajax="false"  class="ui-btn ui-btn-left ui-icon-back ui-corner-all ui-btn-icon-left ui-btn-icon-notext">视图</a>
            <h1>请选择要回复的人</h1>
            <a id="comuser_btn" mp-panel-id="proinfo-listview-panel" href="#" class="ui-btn ui-shadow ui-mini ui-btn-right">确认</a>
        </div>
        <div role="main" class="ui-content" id="comment-user-content"
             mp-url="ajax-comment!usersPage.action">
            <ul data-role="listview" data-theme="a" data-dividertheme="b"
                mp-page="1" mp-keyword="" data-split-icon="forward" data-split-theme="a" data-inset="false">
                <li>
                </li>
            </ul>
            <%--<div>--%>
            <%--<a href="#" key="prePage" class="ui-btn ui-btn-icon-notext ui-corner-all  ui-mini ui-btn-inline ui-icon-carat-l "> 上一页</a>--%>
            <%--<a href="#" key="nextPage" class="ui-btn ui-btn-icon-notext ui-corner-all  ui-mini ui-btn-inline ui-icon-carat-r ">下一页 </a>--%>
            <%--<span class="ui-btn-inline">--%>
            <%--页数  <span key="pageNumber"></span>/<span key="pageCount"></span> 共<span key="totalCount"></span>条--%>
            <%--</span>--%>
            <%--</div>--%>

        </div>
    </div>
</body>
<script type="text/javascript">


//详情页面
$(function() {

    $("a[key=page-main-action]").click(function () {
        $("#head-div").attr("style","display:block");
        $(':mobile-pagecontainer').pagecontainer('change', '#page_main_content', {
            changeHash: false,
            reverse: true,
            transition: 'slideup'
        });
    })
    //批注页面
    $("#page-comment-action").off("click").on("click", function () {
        $("#head-div").attr("style","display:none");
        $(':mobile-pagecontainer').pagecontainer('change', '#page-comment', {
            changeHash: false,
            reverse: true,
            transition: 'slidedown'
        });
        loadListview($("#comment-listview-content"), {}, function (rdata) {
            $("a[key=comment-popup2]").unbind('click').bind("click", function (e) {
                $("#comment-popup2").data("parentId", $(this).attr("parentId")).data("createrId", $(this).attr("createrId"));
                $("#comment-popup2 textarea").attr("placeholder", "@" + $(this).attr("createrName"));
                $("#comment-popup2").popup("open", {transition: 'pop', positionTo: 'window'});
            })
        })
    });
    //文件页面
    $("#page-file-action").off("click").on("click", function () {
        var urlData = $("#urlData").val();
        var prefix = $('#prefix').val();
        var configType =  $('#configType').val();
        if(urlData == "fail"){
            alert('没有文件');
            return;
        }else if(urlData == "error"){
             alert('此文件格式不支持预览');
             return;
        }
        var url = $("#fileUrl").val();
        $("#head-div").attr("style","display:none");
        $(':mobile-pagecontainer').pagecontainer('change', '#page-file', {
            changeHash: false,
            reverse: true,
            transition: 'slidedown'
        });
        if(configType == 2){
            if(prefix == "xls" || prefix == "xlsx"){
                var width = $("body").width()+45;
                $("#file-content").append('<iframe  style="overflow-x:auto !important;margin-left:-30px" align="center" width="'+width+'"  height="800" src="'+url+'" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="yes"></iframe>');
            }else{
                var width = $("body").width()+105;
                $("#file-content").append('<iframe  style="overflow-x:auto !important;margin-left:-70px" align="center" width="'+width+'"  height="800" src="'+url+'" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="yes"></iframe>');
            }
        }else if(configType == 3){
            $("#file-content").append("<img id='loading' src='../resource/com/img/load.jpg' width='20px' height='20px' style='padding-right:5px'/>正在加载页面,请稍候...");
            if(prefix == "xls" || prefix == "xlsx"){
                 var height = $('body').height();
                 var width = $("body").width();
                 $("body").html("<div style='width:'"+width+"';overflow-x: scroll;'><embed  width='100%' height='"+height+"'  src='"+url+"'></div>");
            }else{
                setTimeout(function(){
                    window.location = url;
                },50);
            }
        }else{
            if(prefix == "pdf"){
                    $("#file-content").append( urlData);
                    document.onscroll =function () {
                            GetPageIndex();
                            if (isEnd) { return; }
                            var c = document.body.scrollTop || document.documentElement.scrollTop;
                            var d = window.innerHeight || window.screen.height;
                            var page_file = $('#page-file').height();

                                 if (c + d  >= page_file) {
                                        if (!isIn) {
                                            GetPage();
                                        }
                                        isIn = true;
                                    }
                                    else {
                                        isIn = false;
                                    }
                        }
                }else if(prefix == "xls" || prefix == "xlsx"){
                    $("#file-content").append("<div style='width:1024px;overflow-x: scroll;'><embed  width='100%' height='800'  src='"+url+"'></div>");
                }else{
                       var width = $("body").width()+200;
                      //  $("#file-content").append("<div style='width:500px;overflow-x: scroll;'><embed  width='100%' height='800'  src='"+url+"'></div>");
                       $("#file-content").append('<iframe  style="overflow-x:auto !important;margin-left:-100px;margin-right:200px" align="center" width="'+width+'"  height="800" src="'+url+'" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="yes"></iframe>');
                      //  return;

                }
        }


     });

    //发表批注对话框的提交按钮
    $("#comment-popup2 button").bind("click", function (e) {
        //隐藏popup
        var parentId = $("#comment-popup2").data("parentId");
        var createrId = $("#comment-popup2").data("createrId");
        var text = $("#comment-popup2 textarea").val();

        var targetId = $("#page-comment").attr("targetId");
        var targetObject = $("#page-comment").attr("targetObject");
        //alert(parentId + " " + createrId + " " + text + " " + targetId + " " + targetObject);
        sendComment(parentId, createrId, text, targetId, targetObject, function () {

        });
    })

    $("#btn_choose").click(function(){
        $(':mobile-pagecontainer').pagecontainer('change', '#page-user',{changeHash: false,reverse: true,transition:'slideup'});
        loadListview($("#comment-user-content"),{},function(rdata){

        })
    });
    //发表批注对话框的提交按钮
    $("#chart_btn").bind("click",function(e){
        //alert(1);
        //隐藏popup
        var toUsersId = $( "#hi_ids").val();
       // var createrId = $( "#comment-popup2" ).data("createrId");
        var text = $( "#chart_user" ).val();

        var targetId = $("#page-comment").attr("targetId");
        var targetObject = $("#page-comment").attr("targetObject");
        //alert(parentId + " " + createrId + " " + text + " " + targetId + " " + targetObject);
        sendComment(null,toUsersId,text,targetId,targetObject,function(){
        });
    })


})

$('div[name="p"]').css('width' ,'100% !important');
$('div[name="p"] img').css('width' ,'100% !important');
$("#page-resume-action").off("click").on("click",function(e){
    $(':mobile-pagecontainer').pagecontainer('change', '#page-resume',{changeHash: false,reverse: true,transition:'slidedown'});
    loadListview($("#comment-listview-resume"),{},function(rdata){

    })
});
</script>
<script>
    $(function(){
        $("#comuser_btn").click(function(){
            var ids='';
            var names='';
            $("input[name='check_user']:checked").each(function(i,v){
                ids+=$(this).attr("id")+",";
               // names+="@"+$(this).attr("key")+" ";
            });
            $("#hi_ids").val(ids);
            //$("#chart_user").val(names);
            $(':mobile-pagecontainer').pagecontainer('change', '#page-comment',{changeHash: false,reverse: true,transition:'slideup'});
            var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
            if(isiOS){
                document.body.scrollTop = 90000;

            }
        });

    });

</script>
<script type="text/javascript">
   $(function(){
                 var u = navigator.userAgent, app = navigator.appVersion;
                   var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //android终端或者uc浏览器
                   var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
                   $("#ToolBar").addClass("toolAndroid");
                   if(isiOS){
                       $('#chart_user').focus(function(){
                             var body = $('body').height();
                             var comment_listview = $("#comment-listview-content").height();
                             if(body>comment_listview){
                               document.body.scrollTop = body;
                             }else{
                               $("#ToolBar").removeClass().addClass("toolIos");
                               document.body.scrollTop = comment_listview;
                             }

                       });
                       $('#chart_user').blur(function(){
                            $("#ToolBar").removeClass().addClass("toolAndroid");
                       });
                   }
           });
</script>
</body>
</html>

